import com.gzzn.validate.internal.TestResult;
import com.gzzn.validate.support.Validate;

/**
 * Created by Zhang DP on 14-3-9.
 */
public class MyValidate extends Validate {
    @Override
    public TestResult doValidate(Object input) {
        User user = (User)input;
        String username= user.getUsername();
        String passwd = user.getPasswd();
        boolean passed = username.equals("zhangsan")&&passwd.equals("123456")?true:false;
        String message = user.getUsername()+"没有通过用户验证";

        return new TestResult(passed,message,rule);//自定义不需要改rule,默认使用父类rule
    }
}

class TestMyValidate{

    public static void main(String[] args) {
        Validate myValidate = new MyValidate();
        User userPassed = new User("zhangsan","123456");//zhangsan

        TestResult result1 = myValidate.doValidate(userPassed);
        if(result1.passed) System.out.println("zhangsan通过验证");//通过
        else System.out.println(result1.message);


        User userNopassed = new User("lisi","654321");//lisi

       TestResult result2 = myValidate.doValidate(userNopassed);
        if(result2.passed) System.out.println("lisi通过验证");//没有通过
        else System.out.println(result2.message);
    }


}
